/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:${USER}
 * Date:${YEAR}-${MONTH}-${DAY}
 * ${TIME}
 */
public class Main {
    public String removeDuplicates(String s) {
        StringBuffer ret=new StringBuffer();
        for(int i=0;i<s.length();i++){
            char ch=s.charAt(i);
            if(ret.length()>0&&ch=='#'){
                ret.deleteCharAt(ret.length()-1);//出
            } else if(ret.length()==0&&ch=='#') {

            } else{
                ret.append(ch);//进
            }
        }
        return ret.toString();
    }
    public boolean backspaceCompare(String s, String t) {
        if(removeDuplicates(s).equals(removeDuplicates(t))){
            return true;
        }
        return false;
    }
}